import path from "path";


/**
 * 创建上下文
 * @param {*} context
 * @returns
 */
const createContext = async (files: string[], config: ContextType): Promise<ContextType> => {
    const contextFiles: FileType[] = files.map((file) => {
        const parseFile = path.parse(file)
        return {
            file: file,
            fullPath: path.join(config.projectPath || '', config.globalPath || '', file),
            name: parseFile.name,
            humpDirPath: [...parseFile.dir.split(path.sep), parseFile.name].filter((item) => item).join("."),
        }
    })
    return {
        ...config,
        files: contextFiles
    }
};

export default createContext;